-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: reload failed IPFS tabs when API becomes available #1092
feat: reload failed IPFS tabs when API becomes available #1092
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding explainer comments
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to remove ambiguity from IDEs
// those pages. | ||
// - The benefit we get from this approach is the static nature of just observing the tabs in their current state. | ||
// which reduces the overhead of injecting content scripts to track urls that were loaded after the connection | ||
// was offline, it may also need extra permissions to inject code on error pages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic validates offline pages belonging to IPFS node.
@@ -141,7 +141,7 @@ | |||
"webextension-polyfill": "0.7.0" | |||
}, | |||
"engines": { | |||
"node": ">=14.15.0", | |||
"node": ">=14.15.0 <17", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason latest LTS (18) fails to build this. I did not investigate, but added check to prevent this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. a lot of our packages and their dependencies are out of date, and there have been a lot of changes made w.r.t. esm support, so we've been in a tough spot. However, you can see our support goals at https://github.com/ipfs/ipfs-gui/tree/SgtPooki-version-support-definition#nodejs (We can link to main branch when ipfs/ipfs-gui#97 gets merged)
@@ -141,7 +141,7 @@ | |||
"webextension-polyfill": "0.7.0" | |||
}, | |||
"engines": { | |||
"node": ">=14.15.0", | |||
"node": ">=14.15.0 <17", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. a lot of our packages and their dependencies are out of date, and there have been a lot of changes made w.r.t. esm support, so we've been in a tough spot. However, you can see our support goals at https://github.com/ipfs/ipfs-gui/tree/SgtPooki-version-support-definition#nodejs (We can link to main branch when ipfs/ipfs-gui#97 gets merged)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @whizzzkid, before we land this, do you mind
- rebasing this to include fix from fix(ci): windows build #1094 (which already landed in main branch)
- improving URL check to also work for subdomain gateways (details inline)
- (optional) perhaps we could avoid title matching by leveraging
onErrorOccurred
? (details inline – not a blocker, could be descoped and filled as an issue for future improvement, lmk if you prefer that)
* was offline, it may also need extra permissions to inject code on error pages. | ||
*/ | ||
return url.startsWith(this.customGatewayUrl) && | ||
(url.includes(title) || title.toLowerCase() === 'problem loading page') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nits:
startsWith
does not cover subdomain gateways- mind updating this check to use
isIPFS.url && isIPFS.subdomain
? (see https://www.npmjs.com/package/is-ipfs)
- mind updating this check to use
- browser vendors may change the title (in Firefox it will be different for non-english locale)
- (loose idea, not sure how feasible) potential improvement would be to leverage
onErrorOccurred
fromsrc/lib/ipfs-request.js
and inside of it, addisRecoverableViaOnlineApi
which would save failed requests to local gateway in a cache similar toerrorInFlight
. Then, you could check if url is present in that cache, removing the need for matching titles. More complicated, but future-proof :)
- (loose idea, not sure how feasible) potential improvement would be to leverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @lidel
- the check should be
isIPFS.url || isIPFS.subdomain
and notisIPFS.url && isIPFS.subdomain
added that. - I'll create a separate issue for that, It was on my mind but this PR is large as it is, I'll work on that issue separately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whizzzkid mind linking to the created issue or creating it and commenting here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validation ({ url }) { | ||
const bundled = !url.startsWith('http') && url.includes('/webui/index.html#/') | ||
const ipns = url.includes('/webui.ipfs.io/#/') | ||
return bundled || ipns | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: built-in webui at http://127.0.0.1:5001/webui/
returns redirect to http://127.0.0.1:5001/ipfs/{hardcoded-cid}
(hardcoded-cid here)
It seems to be missing here, is it reloaded by some other means? (if not, we may want to add it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality was brought in from: https://github.com/ipfs/ipfs-companion/blob/main/add-on/src/lib/ipfs-client/index.js#L64-L68
But now that I think more about it, this will be handled in the localGatewayReloader
check as isIPFS.url || isIPFS.subdomain
returns true for http://127.0.0.1:5001/ipfs/bafybeibozpulxtpv5nhfa2ue3dcjx23ndh3gwr5vwllk7ptoyfwnfjjr4q
hardcoded cid.
* main: fix(ci): windows build (ipfs#1094)
@lidel @SgtPooki this is ready for re-review:
Build is now 🟢 https://github.com/whizzzkid/ipfs-companion/actions/runs/3033417199 ❤️ |
@SgtPooki : is there any other feedback, or can this be merged? |
GUI triage: Lidel is going to give a look at this. We need to fix companion build pipeline before merging this |
* was offline, it may also need extra permissions to inject code on error pages. | ||
*/ | ||
return url.startsWith(this.customGatewayUrl) && | ||
(url.includes(title) || title.toLowerCase() === 'problem loading page') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whizzzkid mind linking to the created issue or creating it and commenting here?
GUI triage: Lidel is going to give a look at this. We need to fix companion build pipeline before merging this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @whizzzkid and @SgtPooki
LGTM, there are unrelated issues caused by old dependencies (will fill separate issues if I have no time to fix them myself), but the functionality of this PR is good!
I'm merging it to unblock follow-up work from #1097
it('should handle internal tab reloading', function () { | ||
const tabs = [{ | ||
url: 'http://127.0.0.1:8080/ipfs/cid/wiki1', | ||
id: 1 | ||
}, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whizzzkid in browser context we also need to test subdomain gateway at localhost (one for .ipns.localhost:8080
and one for .ipfs.localhost:8080
) That is what is used by users by default these days.
Not blocking this PR on this, but added it as additional task to #1097 :)
Closes #1010
In this PR:
content_scripts
.yarn.lock
file and added a matching.editorconfig
to configure IDEs.Screencast:
output.mp4